package tp.pr2;

public class Instruction {
	private Action action;
	private Rotation rotation;

	/**
	 * Constructor por defecto.
	 */
	public Instruction() {
		action = Action.UNKNOWN;
		rotation = Rotation.UNKNOWN;
	}

	/**
	 * Crea una instruccion solo con el parametro action
	 * 
	 */
	public Instruction(Action action) {
		this.action = action;
		rotation = Rotation.UNKNOWN;
	}

	/**
	 * Crea una instruccion especificando sus dos parametros
	 */
	public Instruction(Action action, Rotation rotation) {
		this.action = action;
		this.rotation = rotation;
	}

	/**
	 * Comprueba si la instruccion es valida
	 * 
	 * @return false si la accion es UNKNOWN, o la accion es TURN y rotacion
	 *         UNKNOWN. Devuelve true en caso contrario
	 * 
	 */
	public boolean isValid() {
		boolean ret = true;
		if ((action.equals(Action.UNKNOWN) || (action.equals(Action.UNKNOWN) && (rotation
				.equals(Rotation.UNKNOWN))))
				|| action.equals(Action.TURN)
				&& rotation.equals(Rotation.UNKNOWN))
			ret = false;

		return ret;

	}

	/**
	 * Getter del atributo action
	 */
	public Action getAction() {
		return action;
	}

	/**
	 * Getter del atributo rotation
	 */
	public Rotation getRotation() {
		return rotation;
	}

}
